{"ast":null,"code":"import * as React from 'react';\nimport useForceUpdate from '../_util/hooks/useForceUpdate';\nimport { cloneElement } from '../_util/reactNode';\nimport Statistic from './Statistic';\nimport { formatCountdown } from './utils';\nvar REFRESH_INTERVAL = 1000 / 30;\nfunction getTime(value) {\n  return new Date(value).getTime();\n}\nvar Countdown = function Countdown(props) {\n  var value = props.value,\n    _props$format = props.format,\n    format = _props$format === void 0 ? 'HH:mm:ss' : _props$format,\n    onChange = props.onChange,\n    onFinish = props.onFinish;\n  var forceUpdate = useForceUpdate();\n  var countdown = React.useRef(null);\n  var stopTimer = function stopTimer() {\n    onFinish === null || onFinish === void 0 ? void 0 : onFinish();\n    if (countdown.current) {\n      clearInterval(countdown.current);\n      countdown.current = null;\n    }\n  };\n  var syncTimer = function syncTimer() {\n    var timestamp = getTime(value);\n    if (timestamp >= Date.now()) {\n      countdown.current = setInterval(function () {\n        forceUpdate();\n        onChange === null || onChange === void 0 ? void 0 : onChange(timestamp - Date.now());\n        if (timestamp < Date.now()) {\n          stopTimer();\n        }\n      }, REFRESH_INTERVAL);\n    }\n  };\n  React.useEffect(function () {\n    syncTimer();\n    return function () {\n      if (countdown.current) {\n        clearInterval(countdown.current);\n        countdown.current = null;\n      }\n    };\n  }, [value]);\n  var formatter = function formatter(formatValue, config) {\n    return formatCountdown(formatValue, Object.assign(Object.assign({}, config), {\n      format: format\n    }));\n  };\n  var valueRender = function valueRender(node) {\n    return cloneElement(node, {\n      title: undefined\n    });\n  };\n  return /*#__PURE__*/React.createElement(Statistic, Object.assign({}, props, {\n    valueRender: valueRender,\n    formatter: formatter\n  }));\n};\nexport default /*#__PURE__*/React.memo(Countdown);","map":{"version":3,"names":["React","useForceUpdate","cloneElement","Statistic","formatCountdown","REFRESH_INTERVAL","getTime","value","Date","Countdown","props","format","onChange","onFinish","forceUpdate","countdown","useRef","stopTimer","current","clearInterval","syncTimer","timestamp","now","setInterval","useEffect","formatter","formatValue","config","Object","assign","valueRender","node","title","undefined","createElement","memo"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/antd/es/statistic/Countdown.js"],"sourcesContent":["import * as React from 'react';\nimport useForceUpdate from '../_util/hooks/useForceUpdate';\nimport { cloneElement } from '../_util/reactNode';\nimport Statistic from './Statistic';\nimport { formatCountdown } from './utils';\nconst REFRESH_INTERVAL = 1000 / 30;\nfunction getTime(value) {\n  return new Date(value).getTime();\n}\nconst Countdown = props => {\n  const {\n    value,\n    format = 'HH:mm:ss',\n    onChange,\n    onFinish\n  } = props;\n  const forceUpdate = useForceUpdate();\n  const countdown = React.useRef(null);\n  const stopTimer = () => {\n    onFinish === null || onFinish === void 0 ? void 0 : onFinish();\n    if (countdown.current) {\n      clearInterval(countdown.current);\n      countdown.current = null;\n    }\n  };\n  const syncTimer = () => {\n    const timestamp = getTime(value);\n    if (timestamp >= Date.now()) {\n      countdown.current = setInterval(() => {\n        forceUpdate();\n        onChange === null || onChange === void 0 ? void 0 : onChange(timestamp - Date.now());\n        if (timestamp < Date.now()) {\n          stopTimer();\n        }\n      }, REFRESH_INTERVAL);\n    }\n  };\n  React.useEffect(() => {\n    syncTimer();\n    return () => {\n      if (countdown.current) {\n        clearInterval(countdown.current);\n        countdown.current = null;\n      }\n    };\n  }, [value]);\n  const formatter = (formatValue, config) => formatCountdown(formatValue, Object.assign(Object.assign({}, config), {\n    format\n  }));\n  const valueRender = node => cloneElement(node, {\n    title: undefined\n  });\n  return /*#__PURE__*/React.createElement(Statistic, Object.assign({}, props, {\n    valueRender: valueRender,\n    formatter: formatter\n  }));\n};\nexport default /*#__PURE__*/React.memo(Countdown);"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,cAAc,MAAM,+BAA+B;AAC1D,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,SAAS,MAAM,aAAa;AACnC,SAASC,eAAe,QAAQ,SAAS;AACzC,IAAMC,gBAAgB,GAAG,IAAI,GAAG,EAAE;AAClC,SAASC,OAAO,CA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